package com.joint.cloud.common.exception.msg;

import org.springframework.util.StringUtils;

/**
 * @author lilengyi
 * @date 2021/11/12 10:48
 *
 */
public abstract class BaseAIOpsExceptionErrorMsg {

    private String errorCode;

    private String errorMsg;

    private String errorMsgLocal;

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public void setErrorMsgLocal(String errorMsgLocal) {
        this.errorMsgLocal = errorMsgLocal;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        if (!StringUtils.hasLength(this.errorMsg)) {
            this.errorMsg = generateErrorMsg();
        }
        if (!StringUtils.hasLength(this.errorMsg)) {
            this.errorMsg = generateErrorMsgLocal();
        }
        return errorMsg;
    }

    public String getErrorMsgLocal() {
        if (!StringUtils.hasLength(this.errorMsgLocal)) {
            this.errorMsgLocal = generateErrorMsgLocal();
        }
        if (!StringUtils.hasLength(this.errorMsgLocal)) {
            this.errorMsgLocal = generateErrorMsg();
        }
        return errorMsgLocal;
    }

    public abstract String generateErrorMsg();

    public abstract String generateErrorMsgLocal();

}
